package cn.itsource.user.controller;

import cn.itsource.basic.util.AjaxResult;
import cn.itsource.user.domain.User;
import cn.itsource.user.service.ICodeService;
import cn.itsource.user.service.IUserService;
import cn.itsource.user.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserCotroller {

    @Autowired
    private IUserService userService;
    //{"phone":"15008495702","code":"978649","password":"123456","passwordRepeat":"123456"}
    @PostMapping("/register")
    public AjaxResult register(@RequestBody UserVO userVO){
        //保存数据的逻辑
        try {
            userService.register(userVO);
            return  AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return  AjaxResult.me().setMessage(e.getMessage());
        }
    }
}
